//jQ start
$(function () {
    authorities = $.session.get('authorities');
    console.log(authorities);
    show_org_list()
    //查询部分
    $("#org_search_btn").click(function (){
        let orgName = $("#search_org_name").val();
        let pid = $("#search_org_uid").val();
        let state = $("#search_org_des").val();
        show_org_list(orgName,pid,state)
    });

    //显示组织列表方法
    function show_org_list(orgName,pid,state) {
        $("#data-list").empty();
        //ajax start
        $.ajax({
            url: baseURL + '/auth/api/org/getOrgList',
            type: 'post',
            dataType: 'json',
            headers: {'authorities': authorities},
            data: {
                orgName:orgName,
                pid:pid,
                state:state,

            },
            success: function (c) {
                console.log(c.content);
                for (let i = 0; i < c.content.length; i++) {
                    $("#data-list").append(
                        '<tr><td class="sn">' + c.content[i].orgname + '</td><td class="title">' + c.content[i].pid + '</td> <td class="grade">'
                        + c.content[i].state + '</td>' +
                        '<td><a data-toggle="modal" class="modify-modal" href="#modify">修改 </a><a class="del"> 删除</a></td></tr>'
                    )
                }

            }

        })
    }
    //新增组织
    $("#save_org_add").click(function () {
        let add_org_pid = $("#add_org_pid").val();
        let add_org_orgName = $("#add_org_orgName").val();
        let add_org_orgType = $("#add_org_orgType").val();
        console.log(add_org_pid);
        console.log(add_org_orgName);
        console.log(add_org_orgType);
        //ajax start
        $.ajax({
            url: baseURL + '/auth/api/org/addOrg',
            type: 'post',
            dataType: 'json',
            headers: {'authorities': authorities},
            data: {
                pid: add_org_pid,
                orgName: add_org_orgName,
                orgCode: 1,
                description:'测试描述 组织添加',

            },
            success: function (e) {
                console.log(e);
            }

        })
    });


})